package org.redr.canvas;

import java.util.ArrayList;
import java.util.HashMap;

import org.redr.widgetGUI.core.RedRWidgetGUI;

public class GlobalData {
	
	private static boolean RVariableRemoveSupress = false;
	private static boolean CanvasIsClosing = false;
	static HashMap<String, ArrayList<Datum>> data	=	new HashMap<String, ArrayList<Datum>>();
	
	static void addGlobalData(RedRWidgetGUI w, String type, String value){
		addGlobalData(w.widgetID(), type, value);
	}
	
	static void addGlobalData(String id, String type, String value){
		if (data.containsKey(id)){
			data.get(id).add(new Datum(0, value));
		} else {
			data.put(id, new ArrayList<Datum>());
			data.get(id).add(new Datum(0, value));
		}
		
	}
	
	static void addGlobalData(int w, String type, String value){
		if (!data.keySet().contains(type)) data.put(type, new ArrayList<Datum>());
		ArrayList<Datum> d	=	data.get(type);
		Datum newDatum		=	new Datum(w, value);
		d.remove(newDatum);
		d.add(newDatum);
	}
	
	static void removeGlobalData(RedRWidgetGUI w){
		removeGlobalData(w.widgetID());
	}
	
	static void removeGlobalData(String id){
		data.remove(id);
	}
	
	static void removeGlobalData(int w){
		for (ArrayList<Datum> d : data.values()){
			continue;
			
		}
	}

	public static void setRVariableRemoveSupress(boolean b) {
		// TODO Auto-generated method stub
		RVariableRemoveSupress = b;
		
	}
	public static boolean getRVariableRemoveSupress(){
		return RVariableRemoveSupress;
	}

	public static void setCanvasIsClosing(boolean b) {
		// TODO Auto-generated method stub
		CanvasIsClosing = b;
	}
	
	public static boolean getCanvasIsClosing(){
		return CanvasIsClosing;
	}
}
